/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.ifal.bd;

import br.edu.ifal.modelo.Login;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author VagnerSilva
 */
public class LoginBD {

    public boolean loginBD(Login l2) throws SQLException {
        Login l = new Login();
        Connection con = new FabricaConexao().fabricaConexao();
        String sql = "select *from login where usuario like ? and senha like ?";
        PreparedStatement stmt = con.prepareStatement(sql);
        stmt.setString(1, l2.getUsuario());
        stmt.setString(2, l2.getSenha());
        ResultSet rs = stmt.executeQuery();

        if (rs.next()) {
            if (rs.getString("usuario").equals(l2.getUsuario()) && rs.getString("senha").equals(l2.getSenha())) {
                stmt.close();
                con.close();
                return true;
            }
        }
        stmt.close();
        con.close();
        return false;
    }
}
